<link rel="stylesheet" type="text/css" href="__TEMP__/{$style}/public/css/components.css">
<link rel="stylesheet" type="text/css" href="__TEMP__/{$style}/public/css/group_goods_list.css">
<style>
.two-list-menu {
    left: 109px;
	top:45px;
}

.wenzhang_list a{
	line-height: 44px;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    border-bottom: 1px solid #ddd;
	padding: 3px 7px;
	display: block;
}
</style>
<!-- 分类 -->
<div class="custom-tag-list clearfix">
    <div class="mask" id="grouGoodsListmask"></div>
	<div class="custom-tag-list-menu-block" >
		<div style="height: 294px; display: none;"></div>
		<ul class="custom-tag-list-side-menu" style="position: relative;" id='goods_group'>
			{foreach name="platform_help_class" id="class_vo" key="k"}
			<li>
				<a href="javascript:;" data-groupid="{$class_vo.class_id}" onclick="getArticleList({$class_vo.class_id},this,1)" {if condition="$k==0"}class="selected"{/if}>
					<span>{$class_vo.name}</span>
				</a>
			</li>
			{/foreach}
		</ul>
	</div>
		
    <div class="custom-tag-list-goods wenzhang_list" id='article_list'>
        
    </div>
</div>
<!-- 总页数 -->
<input type="hidden" id="page_count">
<!-- 当前页数 -->
<input type="hidden" id="page" value="1">
<!-- 当前所选分类 -->
<input type="hidden" id="class_id" value="">
<script>
$(function(){
	var selece_class_id = $('a.selected').attr('data-groupid');
	getArticleList(selece_class_id,'no',1);
})
var is_load =true;
function getArticleList(class_id,obj,page){
	$("#page").val(page); 
	$("#class_id").val(class_id); 
	if(obj != 'no'){
		$(".custom-tag-list-side-menu li a").removeClass("selected");
		$(obj).addClass("selected");	
	}
	if(is_load){
		is_load = false;
		$.ajax({
			type:"post",
			url : "{:__URL('APP_MAIN/Articlecenter/getArticleList')}",
			async : true,
			data : {'class_id':class_id, 'page':page },
			beforeSend:function(){
				showLoadMaskLayer();
			},
			success : function(data){
				$("#page_count").val(data['page_count']);
				if(page == 1){
					var article_list_html = '';
				}else if(page > 1){
					var article_list_html = $('#article_list').html();
				}
				for(var i =0 ;i<data['data'].length;i++){
					article_list_html +='<a href="'+__URL('APP_MAIN/Articlecenter/articlecontent?article_id='+data['data'][i]['article_id'])+'">'+data['data'][i]['title']+'</a>';
				}
				$('#article_list').html(article_list_html);
				is_load =true;
				hiddenLoadMaskLayer();
			}
		})
	}
	
}
//通过文章ID获取文章内容
 function getgoodlist(id){
	
	return false;
	$('#grouGoodsListmask').hide();
	$('.two-list-menu').hide();
	$('.two-list-menu li[pid]').hide();
	$.ajax({
		type:"post",
		url : "{:__URL('APP_MAIN/Articlecenter/index')}",
		async : true,
		data : {'id':id },
		beforeSend:function(){
			showLoadMaskLayer();
		},
		success : function(data){
			console.log("aa");
			var html = '';
			html+='<p style="padding-left: 40%;">'+data['title']+'</p>';
			if(data['content']==''){
				html+='<p style="font-size:12px;">{:lang("no_relevant_content")}</p>';
			}else{
				html+='<p style="font-size:12px;" id="content_html"></p>';
			}
			$('#good_list').html(html);
			$('#content_html').html(data['content']);
			hiddenLoadMaskLayer();
		}
	});
} 

//滑动到底部加载
$(window).scroll(function(){
	var totalheight = parseFloat($(window).height()) + parseFloat($(window).scrollTop());
	var content_box_height = parseFloat($("#article_list").height()); 
	if(totalheight - content_box_height >= 40){
		if(is_load){
			var page = parseInt($("#page").val()) + 1;//页数
			var total_page_count = $("#page_count").val(); // 总页数
			var class_id = $("#class_id").val();
			if(page > total_page_count){
				return false;
			}else{
				getArticleList(class_id,"no",page);
			}
		}
		
	}
})
</script>
